package com.ll.app.controller.jj;

import com.ll.app.api.jj.*;
import com.ll.base.dto.ApiResultDTO;
import com.ll.domain.jj.base.JJClassBaseService;
import com.ll.domain.jj.base.JJProjectBaseService;
import com.taobao.api.ApiException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/jj/project")
@RequiredArgsConstructor
@Api(tags = "基金项目相关API")
public class JJProjectController {

    private final JJProjectBaseService jjProjectBaseService;

    @ResponseBody
    @ApiOperation(value = "分页查询")
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public ApiResultDTO page(@RequestBody @Validated PageJJProjectReqDTO pageReq)  {
        return ApiResultDTO.success(jjProjectBaseService.page(pageReq));
    }

    @ResponseBody
    @ApiOperation(value = "项目申请")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ApiResultDTO add(@RequestBody @Validated AddJJProjectDTO dto)  {
        return ApiResultDTO.success(jjProjectBaseService.add(dto));
    }

    @ResponseBody
    @ApiOperation(value = "项目审批")
    @RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
    public ApiResultDTO updateStatus(@RequestBody @Validated UpdateJJProjectStatusDTO dto)  {
        return ApiResultDTO.success(jjProjectBaseService.updateStatus(dto));
    }
}


